package com.android.lovely.ui.viewmodel

import androidx.lifecycle.viewModelScope
import com.android.lovely.api.service.botService
import com.android.lovely.api.service.userService
import com.android.lovely.data.ChatHistoryList
import com.android.lovely.framework.BaseLoadViewModel
import com.android.lovely.framework.launchWithLoading

/**
 *
 * @author why
 * @date 2025/3/11 16:56
 */
class ChatHeartListViewModel: BaseLoadViewModel<ChatHistoryList>() {
    override suspend fun requestApi(page: Int, loadSize: Int): List<ChatHistoryList> {
        return userService.getHearList(mapOf("page" to page, "size" to loadSize)).onEach {
            it.insertOrUpdateProfile()
        }
    }

    fun delete(id: Int) {
        viewModelScope.launchWithLoading {
            botService.deleteChat(mapOf("bot_id" to id))
            remove(id)
        }
    }
}